<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
    <title>curl</title>
</head>
<body>
<?php 

    function test($value = '')
    {
        $ch = curl_init("http://top.baidu.com");

        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);


        $data = curl_exec($ch);
        $str = iconv("GB2312", "utf-8", $data);

        $pattern = '@<div id="box-today" class="box-today">.*?<a target="_blank" href=".*?">(?<title>?)</a>.*?事件.*?<a target="_blank" href=".*?">(.*?)</a>@s';

        preg_match($pattern, $str, $matches);
        // var_dump($matches);

        echo $matches['title'];



        curl_close($ch);
    }
    test();
 ?>
</body>
</html>